package zust.se.delicious.action;

import java.util.List;
import java.util.Map;

import zust.se.delicious.service.BookmarkService;
import zust.se.delicious.service.UserService;
import zust.se.delicious.vo.BookmarkBean;
import zust.se.delicious.vo.PageBean;
import zust.se.delicious.vo.SessionUserBean;
import zust.se.delicious.vo.UserBean;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class FollowListAction extends ActionSupport {
	private UserService userService;
	private List<UserBean> userList;
	private PageBean pageBean = new PageBean();

	public String followerList() {
		Map session = ActionContext.getContext().getSession();
		SessionUserBean sessionUser = (SessionUserBean) session.get("sessionUser");
		if (sessionUser != null) {
			userList = userService.getFollowerList(sessionUser.getId(), pageBean);
			System.out.println("follow size=" + userList.size());
			return SUCCESS;
		} else
			return ERROR;
	}

	public List<UserBean> getUserList() {
		return userList;
	}

	public void setUserList(List<UserBean> userList) {
		this.userList = userList;
	}

	public PageBean getPageBean() {
		return pageBean;
	}

	public void setPageBean(PageBean pageBean) {
		this.pageBean = pageBean;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String followingList() {
		Map session = ActionContext.getContext().getSession();
		SessionUserBean sessionUser = (SessionUserBean) session.get("sessionUser");
		if (sessionUser != null) {
			userList = userService.getFollowingList(sessionUser.getId(), pageBean);
			System.out.println("follow size=" + userList.size());
			return SUCCESS;
		} else
			return ERROR;

	}

}
